package com.cheetah.cloud2020.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.activerecord.Model;

import java.time.LocalDateTime;

public class BaseEntity<T> extends Model {
    @TableId(type = IdType.AUTO)
    private Integer id;
    /**
     * 状态，目前可以用来代表逻辑删除标志
     * 1正常 0已删除
     */
    private Short state = 0;
    @TableField("update_time")
    private LocalDateTime updateTime = LocalDateTime.now();

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Short getState() {
        return state;
    }

    public void setState(Short state) {
        this.state = state;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    public boolean isDelete() {
        return this.state == 0;
    }

    public static <T> QueryWrapper<T> queryWrapper() {
        return new QueryWrapper<T>().eq("state", 0);
    }
}
